package com.reform.controller.common;


import com.reform.pojo.common.Record;
import com.reform.res.Result;
import com.reform.service.IRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mortale
 * @since 2021-08-05
 */
@RestController
@Api(tags = "RecordController")
@RequestMapping("/record")
public class RecordController {

    @Autowired
    IRecordService recordService;

    @ApiOperation(value = "获取所有日志", notes = "获取所有日志")
    @PostMapping("/getAllRecord")
    @ApiImplicitParams({
    })
    public Result getAllRecord() {
        return recordService.getAllRecord();
    }

    @ApiOperation(value = "根据项目id获取所有日志", notes = "根据项目id获取所有日志")
    @PostMapping("/getRecordByProId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "proId", value = "项目id", paramType = "query", dataTypeClass = String.class, required = true)
    })
    public Result getRecordByProId(String proId) {
        return recordService.getRecordByProId(proId);
    }

    @ApiOperation(value = "根据项目id或教师工号获取所有日志", notes = "根据项目id或教师工号获取所有日志")
    @PostMapping("/getRecordByProIdOrGH")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "proId", value = "项目id", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "gh", value = "教师工号", paramType = "query", dataTypeClass = String.class)
    })
    public Result getRecordByProIdOrGH(String proId, String gh) {
        return recordService.getRecordByProIdOrGH(proId, gh);
    }

    @ApiOperation(value = "新建日志", notes = "新建日志")
    @PostMapping("/creatRecord")
    @ApiImplicitParams({
    })
    public Result creatRecord(Record record) {
        return recordService.creatRecord(record);
    }
}
